#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
__author__ = "Administrator"
__name__="multiprocess"
__date__="2016/8/1"
__time__="11:32"
"""
import time
from multiprocessing import Pool

"""
# 串行--需要10s
def f(n):
    time.sleep(1)
    print n*n
    return n*n

a=range(10)
#print a
print map(f, a)
"""


# 多进程方式：启动10个进程一次打印
# 多进程的第一种写法
def f(n):
    time.sleep(1)
    print n * n
    return n * n


a = range(10)

if __name__ == '__main__':
    p = Pool(10)
    print p.map(f, a)

